1. The Field of the Invention
The present invention relates generally to computing pixel shades in a computer graphics system. More specifically, the present invention provides undiminished image quality for scene details behind transparent polygons by implementing a multi-sample data structure to thereby derive the final pixel shade.
2. The State of the Art
The state of the art in rendering realistic appearing objects on a computer display is complicated by the types of objects which can be rendered. For example, transparent (meaning partially transparent) objects make the task of determining the shading of a pixel more complicated. This is because all of the partially visible objects contribute to the final determination of how the pixel will appear in terms of color, intensity, etc.
Multi-sampling is a method for providing a crude type of pixel transparency effect. More specifically, it is the process for computing polygon surface values at several locations within a single pixel, and then combining these values according to predefined rules which account for the color, coverage, range and opacity of the different surfaces which occupy the pixel. The polygon surface values include selectable attributes which can be displayed in a pixel. These polygon surface values are hereinafter also referred to as samples, where samples are computed at several different places within a single pixel. Each sample can belong to a different polygon surface. Therefore, a computer graphics system must be able to handle, within each pixel, as many different polygons as there are samples.
Multi-sampling is a method which is typically employed to improve the appearance of polygon edges. By enabling polygons to only partially cover pixels, multiple objects can all contribute to the final pixel shading, as opposed to a previous "all or nothing" approach in which each pixel can have only one polygon "claim" it and thus display the attributes or values of a single polygon.
When using the "all or nothing" approach, the polygon which typically claimed a pixel of interest was the "closest" polygon. It was thus assumed that the "closest" polygon was completely obscuring all other polygons which were farther away and assumed to be covered by the "closest" polygon. However, multi-sampling enables the "sharing" of a pixel, so that multiple polygons can contribute to a pixels displayable attributes.
Another important concept to understand before introducing the present invention is that of a sample mask. A sample mask is a binary representation of all of the samples within a single pixel. One bit is assigned to each sample within a pixel. The bit indicates whether that sample is currently occupied by a polygon. In effect, the sample mask is a two-dimensional schematic representation of the way in which a polygon covers a pixel. State of the art multi-sample systems simultaneously employ different sample masks. For example, one type of mask that is associated with a pixel can record the cumulative coverage of that pixel by all prior polygons. Another type of sample mask is associated with a current polygon being rendered. The mask indicates which samples are to be associated with or claimed by the polygon.
Sample masks are also used to control polygon operations. For example, boolean operations on the masks are the means by which new polygons are merged into a pixel, and also determine how the polygons interact with each other. Accordingly, as each new polygon is rendered into a pixel, the system uses all of the masks associated with the prior polygons to determine if overlap exists within the pixel. The multi-sampling system can then use range or rendering order to decide which samples need to be re-assigned to the new polygon, or deleted from the new polygon.
As final pixel shading of pixels is computed, the color of the pixel is obviously an essential component of that calculation. The color of a pixel is computed from all of its samples by summing the color values from each, and then normalizing for the number of samples. Because there is only one color at each sample (which color comes from the polygon which "won" or can "claim" the sample), the summation is generally straightforward and economical in terms of computation resources and time.
State of the art multi-sample approaches to pixel rendering are found to be particularly relevant for graphics systems which must process scenes in arbitrary, as opposed to strict front-to-back order. However, these Z-buffer or R-buffer systems do not arrive at a correct final image until all of the polygons have been rendered. Therefore, they must store information regarding all of the polygons that affect a pixel. The Z-buffer and R-buffer processes are therefore inefficient.
It should now be apparent that the state of the art methods of multi-sampling can be used to provide a type of transparency effect. If a polygon is transparent, its degree of transparency can be approximated by disabling a portion of the pixel samples it might otherwise claim. For example, if a first polygon is 67% transparent (and thus 33% opaque), then 67% of the pixel samples are first disabled, thereby leaving a pattern of "holes" in the sample mask of the first polygon. The samples that remain associated with the first polygon are then treated as if they were fully opaque. The disabled samples can then be claimed by other polygons which are subsequently rendered and which lie beyond the first polygon. These other polygons will then associate their color and other attributes with those remaining samples. These other polygons will thus partially show through the sample mask of the first polygon, thus completing the illusion of transparency.
The process described above is commonly referred to as "screen-door" transparency. The number of transparency levels available is determined by the number of samples within a pixel. For example, if eight samples are provided, transparency is quantized to eight levels. If the number of samples within a pixel is modestly large, useful transparency effects are achievable.
There are some drawbacks associated with multisampling methods. For example, it should be apparent that partially transparent polygons have fewer pixel samples available for polygon edge antialiasing. The result is that the edges of partially transparent polygons are rendered with lower edge quality than opaque polygons. The problem is actually worse than the diminished sample count would suggest, because in general the holes in the sample mask associated with each transparency level can not be uniformly distributed across the pixel. Furthermore, the method of screen-door transparency seriously degrades the image quality of scene details that lie behind a transparent polygon, because polygon edge quality is related to the number of samples within a pixel.
For example, a transparent polygon disables some of these samples by claiming them in proportion to its level of opacity. Opaque scene details behind a transparent polygon have fewer samples available to smooth and antialias their edges. Consequently, small or thin scene details that otherwise would behave acceptably will break up, segment, scintillate and generally misbehave when rendered behind transparent polygons. Edges will thus become progressively more jagged as the remaining number of samples decreases.
Another drawback of state of the art multi-sampling methods is that "screen-door" approaches can not properly represent the visual effect of several overlaid transparent polygons. For example, if two polygons that are each 50% transparent are placed on top of each other, the back or farther polygon will not show up at all because its screen-door holes line up with the holes in the front or closest polygon, and its remaining samples are blocked by the surviving samples of the front polygon.
One method of overcoming this problem would be to provide two different screen-door patterns for 50% transparency situations, and ensuring that overlapped polygons are assigned different versions of 50% transparency masks. Unfortunately, however, even then the combined effect is not correct. The situation becomes worse for arbitrary combinations of different transparency levels, and the problem becomes completely intractable when considering three or more overlaid transparent polygons.
Accordingly, it would be an advantage over the state of the art to provide a method and apparatus for combining multiple combinations of transparencies that will result in accurate pixel rendering, and improved detail.